﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Net;

namespace lapinou_game2
{
    class Sprite
    {
        Vector2 position;
        Texture2D texture;
        public bool screen = true;
        string Name_texture;
        

        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        public Sprite(Vector2 position)
        {
            this.position = position;
        }

        public Sprite(float X, float Y)
        {
            position = new Vector2(X, Y);
        }

        public void LoadContent(ContentManager content, string assetName)
        {
            texture = content.Load<Texture2D>(assetName);
            Name_texture = assetName;
        }

        public int getWidth()
        {
            return texture.Width;
        }

        public string getName_texture()
        {
            return Name_texture;
        }

        public float largeur()
        {
            return texture.Width;
        }

        public float hauteur()
        {
            return texture.Height;
        }

        public bool sreened(GraphicsDeviceManager graphics)
        {
            bool screen = true;
            if (position.X > graphics.PreferredBackBufferWidth || position.X < 0)
                screen = false;
            if (position.Y > graphics.PreferredBackBufferHeight || position.Y < 0)
                screen = false;

            return screen;
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, position, Color.White);
        }

        public void Draw(SpriteBatch spriteBatch, Vector2 scalingCoords)
        {
            spriteBatch.Draw(texture, new Rectangle((int)position.X, (int)position.Y, (int)scalingCoords.X, (int)scalingCoords.Y), Color.White);
        }

        public void setPos(Vector2 pos)
        {
            position = pos;
        }

        public void setPos(int x, int y)
        {
            position.X = x;
            position.Y = y;
        }
    }
}
